package com.example.test.a20240530;

import org.apache.commons.lang3.ArrayUtils;

import java.util.Arrays;
import java.util.Scanner;

public class HJ58输入n个数输出最小的k个 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        final String s = in.nextLine();
        final String s1 = in.nextLine();


        final String[] s2 = s.split(" ");
        int n = Integer.parseInt(s2[0]);
        int k = Integer.parseInt(s2[1]);

        final String[] s3 = s1.split(" ");
        bubbleSort(s3);

        for (int j = 0; j < k; j++) {
            System.out.print(s3[j] + " ");
        }

    }

    static void bubbleSort(String[] arr) {
        boolean falg = false;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {

                if (Integer.parseInt(arr[j]) > Integer.parseInt(arr[j + 1])) {
                    String temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                    falg = true;
                }
            }
            if (falg == false) {
                break;
            } else {
                falg = false;
            }
        }
    }

}
